from dataclasses import dataclass, field
from typing import Self

from poker_bot.core.models.enums.deposit import DepositStatus


@dataclass
class DepositEntity:
    payment_method_id: int
    account_id: int
    status: DepositStatus = field(default=DepositStatus.waiting_payment)
    id: int | None = None
    summ: float | None = None
    buyer_db_id: int | None = None
    invoice_screenshot_path: str | None = None

    @classmethod
    def create(
        cls,
        summ: float,
        buyer_db_id: int,
        payment_method_id: int,
        account_id: int,
    ) -> Self:
        order = cls(
            summ=summ,
            buyer_db_id=buyer_db_id,
            payment_method_id=payment_method_id,
            account_id=account_id,
        )

        return order

    def update_status(self, status: DepositStatus):
        self.status = status

    def update_payment_method(self, payment_method_id: int):
        self.payment_method_id = payment_method_id

    def update_invoice_path(self, invoice_filename: str):
        self.invoice_screenshot_path = invoice_filename
